const state = {
  token: '',
  getUserInfo: {},
};
const mutations = {
  GET_TOKEN(state, token) {
    state.token = token;
    console.log(state.token);
  },
  GET_USERINFO(state, userInfo) {
    state.getUserInfo = userInfo;
    // console.log(state.getUserInfo);
  },
};
const actions = {
  //获取token
  async getToken({ commit }, users) {
    //发送请求，获取token
    const result = await this._vm.$API.users.reqToLogin(users);
   
    commit('GET_TOKEN', result.token);
  },
  //通过token获取用户信息
  async getUserInfo({ commit }) {
    const result = await this._vm.$API.users.reqGetUserInfo();
     // console.log(result);
    commit('GET_USERINFO', result);
  },
};
const getters = {};
export default {
  state,
  mutations,
  actions,
  getters,
};
